Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.os.linux.tls: Refactor, improve documentation, fix a bug, and port to more architectures #20857

Merged
merged 8 commits into from
Aug 1, 2024

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Jul 29, 2024

I don't normally like to propose refactors like this, but I think it's warranted here. I like to think I'm pretty good at understanding obscure ABI stuff, but I really struggled with this particular module initially. It's not helped by the fact that there's a lot of incorrect/incomplete information floating around on the internet. So, I renamed things to (hopefully) be more clear, added more in-depth (and correct) documentation, and replaced some pointer manipulation with a struct.

Once I understood the module, it became clearer that there was something off-looking about the layout computation for the modified Variant I. I verified that it was indeed broken by testing on PPC64, and also fixed that.

Finally, I ported the module to all the architectures I've been doing porting work for:

  • For loongarch, m68k, and s390x, I just used upstream musl code as a reference.
  • For hexagon, I used their musl fork as reference.
  • For arc, I partially referred to the ABI document, but since that has incomplete information on TLS, I deciphered the variant information from glibc.
  • For csky, the ABI document is basically useless on the subject of TLS, so I deciphered all of the ABI details from glibc.

@alexrp alexrp requested a review from kprotty as a code owner July 29, 2024 10:36
lib/std/os/linux/tls.zig Outdated Show resolved Hide resolved
@andrewrk
Copy link
Member

andrewrk commented Aug 1, 2024

Great work, appreciate the detailed writeup.

@andrewrk andrewrk merged commit 91163b4 into ziglang:master Aug 1, 2024
10 checks passed
@alexrp alexrp deleted the tls-porting branch August 1, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants